]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
search: Use a variable for tracking allocated width
authorKhalid Abu Shawarib <kas@gnome.org>
Tue, 2 Sep 2025 22:21:00 +0000 (01:21 +0300)
committerFlorian Müllner <fmuellner@gnome.org>
Sat, 13 Sep 2025 17:03:43 +0000 (19:03 +0200)
Instead of the x coordinates of the allocation box.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3851>
(cherry picked from commit 1e53578362ab7e0575bfa37788f20deabecf8e7f)

js/ui/search.js

index 9b513136d6839a14cf9b9b273fb8717483d50acb..620ad3ddb95a0422d8ddf045f4f194865ea510b9 100644 (file)
@@ -399,8 +399,7 @@ const GridSearchResultsLayout = GObject.registerClass({
         const width = box.get_width();
 
         const childBox = new Clutter.ActorBox();
-        childBox.x1 = 0;
-        childBox.y1 = 0;
+        let accumulatedWidth = 0;
 
         let first = true;
         for (let child of container) {
@@ -410,20 +409,21 @@ const GridSearchResultsLayout = GObject.registerClass({
             if (first)
                 first = false;
             else
-                childBox.x1 += this._spacing;
+                accumulatedWidth += this._spacing;
 
             const [childWidth] = child.get_preferred_width(-1);
             const [childHeight] = child.get_preferred_height(-1);
 
-            if (childBox.x1 + childWidth <= width)
+            childBox.set_origin(accumulatedWidth, 0);
+            accumulatedWidth += childWidth;
+
+            if (accumulatedWidth <= width)
                 childBox.set_size(childWidth, childHeight);
             else
                 childBox.set_size(0, 0);
 
             child.allocate(childBox);
             child.can_focus = childBox.get_area() > 0;
-
-            childBox.x1 += childWidth;
         }
     }